# Config file for MOAB; use the CMake find_package() function to pull this into
# your own CMakeLists.txt file.
#
# This file defines the following variables:
# MOAB_FOUND        - boolean indicating that MOAB is found
# MOAB_VERSION   - version of MOAB
# MOAB_INCLUDE_DIRS - include directories from which to pick up MOAB includes
# MOAB_LIBRARIES    - libraries need to link to MOAB; use this in target_link_libraries for MOAB-dependent targets
# MOAB_CXX, MOAB_CC, MOAB_F77, MOAB_FC - compilers used to compile MOAB
# MOAB_CXXFLAGS, MOAB_CCFLAGS, MOAB_FFLAGS, MOAB_FCFLAGS - compiler flags used to compile MOAB; possibly need to use these in add_definitions or CMAKE_<LANG>_FLAGS_<MODE> 

set(MOAB_FOUND 1)

set(MOAB_VERSION @PACKAGE_VERSION@)

# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${MOAB_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
  set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
  set(PACKAGE_VERSION_COMPATIBLE TRUE)
  if("${MOAB_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
    set(PACKAGE_VERSION_EXACT TRUE)
  endif()
endif()

set(MOAB_CC "@CC@")
set(MOAB_CXX "@CXX@")
set(MOAB_FC "@FC@")
set(MOAB_F77 "@F77@")
# Compiler flags used by MOAB
set(MOAB_CFLAGS "@CFLAGS@")
set(MOAB_CXXFLAGS "@CXXFLAGS@")
set(MOAB_FCFLAGS "@FCFLAGS@")
set(MOAB_FFLAGS "@FFLAGS@")

set(MOAB_BUILT_SHARED @enable_shared@)
set(MOAB_USE_MPI @enablempi@)
set(MPI_DIR "@MPI_DIR@")
set(MOAB_USE_HDF5 @enablehdf5@)
set(MOAB_USE_HDF5_PARALLEL @enablehdf5parallel@)
set(HDF5_DIR "@HDF5_DIR@")
set(MOAB_USE_ZLIB @enablezlib@)
set(ZLIB_DIR "@ZLIB_DIR@")
set(MOAB_USE_SZIP @enableszip@)
set(SZIP_DIR "@SZIP_DIR@")
set(MOAB_USE_NETCDF @enablenetcdf@)
set(NETCDF_DIR "@NETCDF_DIR@")
set(MOAB_USE_PNETCDF @enablepnetcdf@)
set(PNETCDF_DIR "@PNETCDF_DIR@")
set(MOAB_USE_METIS @enablemetis@)
set(METIS_DIR "@METIS_DIR@")
set(MOAB_USE_PARMETIS @enableparmetis@)
set(PARMETIS_DIR "@PARMETIS_DIR@")
set(MOAB_USE_ZOLTAN @enablezoltan@)
set(ZOLTAN_DIR "@ZOLTAN_DIR@")
set(MOAB_USE_BLAS @enable_blaslapack@)
set(BLAS_LIBRARIES "@BLAS_LIBS@")
set(MOAB_USE_LAPACK @enable_blaslapack@)
set(LAPACK_LIBRARIES "@LAPACK_LIBS@")
set(MOAB_USE_EIGEN @enableeigen@)
set(EIGEN3_DIR "@EIGEN3_DIR@")
set(TEMPESTREMAP_DIR "@TEMPESTREMAP_DIR@")
set(MOAB_USE_TEMPESTREMAP @enabletempestremap@)

set(MOAB_MESH_DIR "@abs_top_srcdir@/MeshFiles/unittest")

# Library and include defs
get_filename_component(MOAB_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

include (${MOAB_CMAKE_DIR}/ResolveCompilerPaths.cmake)

set (MOAB_PACKAGE_LIBS "@EXPORT_LDFLAGS@ @TEMPESTREMAP_LIBS@ @ZOLTAN_LIBS@ @PNETCDF_LIBS@ @NETCDF_LIBS@ @CGNS_LIBS@ @HDF5_LIBS@ @DAMSEL_LIBS@ @CCMIO_LIBS@ @PARMETIS_LIBS@ @METIS_LIBS@ @LAPACK_LIBS@ @BLAS_LIBS@ @LIBS@")
string(STRIP "${MOAB_PACKAGE_LIBS}" MOAB_PACKAGE_LIBS)
#set(MOAB_PACKAGE_LIBS_LIST ${MOAB_PACKAGE_LIBS})
#separate_arguments(MOAB_PACKAGE_LIBS_LIST)
#list(REMOVE_DUPLICATES MOAB_PACKAGE_LIBS_LIST)
#set(MOAB_PACKAGE_LIBS "${MOAB_PACKAGE_LIBS_LIST}")

set (MOAB_PACKAGE_INCLUDES_LIST "@ZOLTAN_INC_FLAGS@ @PNETCDF_CPPFLAGS@ @NETCDF_CPPFLAGS@ @HDF5_CPPFLAGS@ @PARMETIS_INCLUDES@ @METIS_INCLUDES@ @TEMPESTREMAP_INCLUDE@ @EIGEN3_INCLUDES@" )
string(STRIP "${MOAB_PACKAGE_INCLUDES_LIST}" MOAB_PACKAGE_INCLUDES_LIST)
RESOLVE_INCLUDES(MOAB_PACKAGE_INCLUDES "${MOAB_PACKAGE_INCLUDES_LIST}")
separate_arguments(MOAB_PACKAGE_INCLUDES)
list(REMOVE_DUPLICATES MOAB_PACKAGE_INCLUDES)

#if(NOT TARGET MOAB AND NOT MOAB_BINARY_DIR)
#  include("${MOAB_CMAKE_DIR}/MOABTargets.cmake")
#endif()

# Target information
if(MOAB_USE_HDF5)
  if(EXISTS "@HDF5_DIR@/share/cmake/hdf5/hdf5-config.cmake")
    include(@HDF5_DIR@/share/cmake/hdf5/hdf5-config.cmake)
  endif()
endif()

set(MOAB_LIBRARY_DIRS "@prefix@/lib")
set(MOAB_INCLUDE_DIRS "@prefix@/include" ${MOAB_PACKAGE_INCLUDES})

set(MOAB_LIBS "-lMOAB")
set(MOAB_LIBRARIES "-L@prefix@/lib ${MOAB_LIBS} ${MOAB_PACKAGE_LIBS}")

